<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>gtild</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : April 1993</div>
    <p>
      <b>gtild</b> -  tilde operation</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>Gt=gtild(G)  </tt>
      </dd>
      <dd>
        <tt>Gt=gtild(G,flag)  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>G</b>
        </tt>: either a polynomial or a linear system (<tt>
          <b>syslin</b>
        </tt> list) or a rational matrix</li>
      <li>
        <tt>
          <b>Gt</b>
        </tt>: same as G</li>
      <li>
        <tt>
          <b>flag</b>
        </tt>: character string: either <tt>
          <b>'c'</b>
        </tt> or <tt>
          <b>'d'</b>
        </tt> (optional parameter).</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    If <tt>
        <b>G</b>
      </tt> is a polynomial matrix (or a polynomial), <tt>
        <b>Gt=gtild(G,'c')</b>
      </tt>
    returns the polynomial matrix <tt>
        <b>Gt(s)=G(-s)'</b>
      </tt>.</p>
    <p>
    If <tt>
        <b>G</b>
      </tt> is a polynomial matrix (or a polynomial),  <tt>
        <b>Gt=gtild(G,'d')</b>
      </tt> 
    returns the polynomial matrix <tt>
        <b>Gt=G(1/z)*z^n</b>
      </tt> where n is the maximum
    degree of <tt>
        <b>G</b>
      </tt>.</p>
    <p>
    For continuous-time systems represented in state-space by a <tt>
        <b>syslin</b>
      </tt> list,
    <tt>
        <b>Gt = gtild(G,'c')</b>
      </tt> returns a state-space representation
    of <tt>
        <b>G(-s)'</b>
      </tt> i.e the <tt>
        <b>ABCD</b>
      </tt> matrices of <tt>
        <b>Gt</b>
      </tt> are
    <tt>
        <b>A',-C', B', D'</b>
      </tt>. If <tt>
        <b>G</b>
      </tt> is improper (<tt>
        <b> D= D(s)</b>
      </tt>) 
    the <tt>
        <b>D</b>
      </tt> matrix of <tt>
        <b>Gt</b>
      </tt> is <tt>
        <b>D(-s)'</b>
      </tt>.</p>
    <p>
    For  discrete-time systems represented in state-space by a <tt>
        <b>syslin</b>
      </tt> list,
    <tt>
        <b>Gt = gtild(G,'d')</b>
      </tt> returns a state-space representation
    of <tt>
        <b>G(-1/z)'</b>
      </tt> i.e the (possibly improper) state-space 
    representation of <tt>
        <b>-z*C*inv(z*A-B)*C + D(1/z) </b>
      </tt>.</p>
    <p>
    For rational matrices, <tt>
        <b>Gt = gtild(G,'c')</b>
      </tt> returns the rational
    matrix <tt>
        <b>Gt(s)=G(-s)</b>
      </tt> and <tt>
        <b>Gt = gtild(G,'d')</b>
      </tt> returns the
    rational matrix <tt>
        <b>Gt(z)= G(1/z)'</b>
      </tt>.</p>
    <p>
    The parameter <tt>
        <b>flag</b>
      </tt> is necessary when <tt>
        <b>gtild</b>
      </tt> is called with
    a polynomial argument.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

//Continuous time
s=poly(0,'s');G=[s,s^3;2+s^3,s^2-5]
Gt=gtild(G,'c')
Gt-horner(G,-s)'   //continuous-time interpretation
Gt=gtild(G,'d');
Gt-horner(G,1/s)'*s^3  //discrete-time interpretation
G=ssrand(2,2,3);Gt=gtild(G);   //State-space (G is cont. time by default)
clean((horner(ss2tf(G),-s))'-ss2tf(Gt))   //Check
// Discrete-time 
z=poly(0,'z');
Gss=ssrand(2,2,3);Gss('dt')='d'; //discrete-time
Gss(5)=[1,2;0,1];   //With a constant D matrix
G=ss2tf(Gss);Gt1=horner(G,1/z)';
Gt=gtild(Gss);
Gt2=clean(ss2tf(Gt)); clean(Gt1-Gt2)  //Check
//Improper systems
z=poly(0,'z');
Gss=ssrand(2,2,3);Gss(7)='d'; //discrete-time
Gss(5)=[z,z^2;1+z,3];    //D(z) is polynomial 
G=ss2tf(Gss);Gt1=horner(G,1/z)';  //Calculation in transfer form
Gt=gtild(Gss);    //..in state-space 
Gt2=clean(ss2tf(Gt));clean(Gt1-Gt2)  //Check
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="../elementary/syslin.htm">
        <tt>
          <b>syslin</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="../polynomials/horner.htm">
        <tt>
          <b>horner</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="../polynomials/factors.htm">
        <tt>
          <b>factors</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
